home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcl
/
cl-nd-cl.lha
/
clue-and-clio-advice
Wrap
Lisp/Scheme
|
1992-04-07
|
11KB
|
332 lines
Here are some things you can do to sutup clue and clio:
CLUE (Common Lisp User-Interface Environment) is from TI,
and extends CLX to provide a simple, object-oriented toolkit
(like Xt) library that uses CLOS. Provides basic window
classes, some stream I/O facilities, and a few other
utilities. Still pretty low level (it's a toolkit, not widget library).
Available free by anonymous ftp from csc.ti.com:pub/clue.tar.Z
Written by Kerry Kimbrough. Send bug reports to
clue-bugs@dsg.csc.ti.com. The users group mailing list is
clue-review@dsg.csc.ti.com (send mail to
clue-review-request@dsg.csc.ti.com to be added to the list).
CLIO (Common Lisp Interactive Objects) is a GUI from the
people who created CLUE. It provides a set of CLOS classes
that represent the standard components of an object-oriented
user interface -- such as text, menus, buttons, scroller, and dialogs.
It is included as part of the CLUE distribution, along with
some packages that use it, both sample and real.
1) get clue.tar.Z, and untar it, so that its root directory is in
the directory that contains pcl and clx.
2) rename all the .l files to .lisp:
foreach i (*/*.l */*/*.l)
mv $i $i.lisp
end
3) create the following files:
----------- systems/clue.lisp --------------
;;; -*- Mode: Lisp; Package: DSYS; Base: 10; Syntax: Common-Lisp -*-
(in-package "DSYS")
(set-system-source-file 'clue (subfile '("clue" "clue") :name "sysdef"))
;(pushnew 'clue *auto-load-systems*)
----------- systems/clio.lisp --------------
;;; -*- Mode: Lisp; Package: DSYS; Base: 10; Syntax: Common-Lisp -*-
(in-package "DSYS")
(set-system-source-file 'clio (subfile '("clue" "clio") :name "sysdef"))
;(pushnew 'clio *auto-load-systems*)
----------- systems/clio-examples.lisp --------------
;;; -*- Mode: Lisp; Package: DSYS; Base: 10; Syntax: Common-Lisp -*-
(in-package "DSYS")
(set-system-source-file 'clio-examples
(subfile '("clue" "clio" "examples") :name "sysdef"))
;(pushnew 'clio-examples *auto-load-systems*)
----------- clue/clue/sysdef.lisp --------------
;;; -*- Mode: Lisp; Package: DSYS; Base: 10; Syntax: Common-Lisp -*-
(in-package "DSYS")
(defsystem clue
(:pretty-name "CLUE")
(:module common-lisp common-lisp (:type :system))
(:module clx clx (:type :system))
(:parallel
common-lisp
clx
(:forms :compile
(progn
(setq *compile-system-proclamation*
'(optimize (speed 3) (safety 0) #+lucid (compilation-speed 3)))
(proclaim *compile-system-proclamation*)
#+akcl (setq compiler::*compile-ordinaries* t)))
(:parallel
"clue" ;; Define packages
(:load "precom")
;;"clx-patch" ;; Modify xlib:create-window
;;"window-doc" ;; pointer documentation window support
"event-parse" ;; Utilities for event translation
"defcontact" ;; CLOS extension for resources and type conversion
"intrinsics" ;; The "guts"
"caches" ;; Support for gcontext, pixmap, cursor cacheing
"resource" ;; Resource and type conversion
"gray" ;; Gray stipple patterns
"cursor" ;; Standard cursor names
"events" ;; Event handling
"virtual" ;; Support for windowless contacts
"shells" ;; Support for top-level window/session mgr interaction
"root-gmgmt" ;; Geometry management methods for root contacts
;;"stream" ;; interactive-stream (non-portable!!)
"package" ;; External cluei symbols exported from clue
"menu" ;; example
(:compile "precom")
)))
----------- clue/clio/sysdef.lisp --------------
;;; -*- Mode: Lisp; Package: DSYS; Base: 10; Syntax: Common-Lisp -*-
(in-package "DSYS")
(defsystem clio
(:pretty-name "Common Lisp Interactive Objects")
(:module clue clue (:type :system))
(:parallel
clue
(:parallel
(:forms :compile
(progn
(setq *compile-system-proclamation*
'(optimize (speed 3) (safety 0) #+lucid (compilation-speed 3)))
(proclaim *compile-system-proclamation*)
#+akcl (setq compiler::*compile-ordinaries* t)))
"clio"
"ol-defs"
"utility"
"core-mixins"
"gravity"
"buffer"
"text-command"
"display-text"
"ol-images"
"buttons"
"confirm"
"scroller"
"table"
"choices"
"form"
"menu"
"psheet"
"command"
"edit-text"
"slider"
"scroll-frame"
"mchoices"
"dlog-button"
"display-imag"
)))
----------- clue/clio/examples/sysdef.lisp --------------
;;; -*- Mode: Lisp; Package: DSYS; Base: 10; Syntax: Common-Lisp -*-
(in-package "DSYS")
(defsystem clio-examples
(:pretty-name "CLIO Example Programs")
(:module clio clio (:type :system))
(:parallel
clio
(:parallel
(:forms :compile
(progn
(setq *compile-system-proclamation*
'(optimize (speed 3) (safety 0) #+lucid (compilation-speed 3)))
(proclaim *compile-system-proclamation*)
#+akcl (setq compiler::*compile-ordinaries* t)))
"package"
(:load "precom")
"cmd-frame"
"sketchpad"
"sketch"
(:compile "precom"))))
------------------------------------------------------------
4) Add these lines from defsystem.lisp to the top of clue.lisp
(after the in-package form).
;; Ensure VALUES is a legal declaration
(proclaim '(declaration values))
;; Ensure *features* knows about CLOS and PCL
(when (find-package 'pcl)
(pushnew :pcl *features*)
(pushnew :clos *features*))
(when (find-package 'clos)
(pushnew :clos *features*))
;; Ensure *features* knows about the Common Lisp Error Handler
(when (find-package 'conditions)
(pushnew :cleh *features*))
*** Note: The following several changes are because slot-value access
within defmethods specialized on a structure-class are very efficient
(in March 92 PCL, at least).
5) If you want,
a) add (:metaclass structure-class) to the definition of
event in clue/clue/events.lisp
b) change allocate-event to be
(defun allocate-event ()
;; Get an event structure, initializing all slots to NIL
(initialize-event (or (pop *event-cache*)
(make-instance 'event))))
c) and change initialize-event to begin like this:
(defmethod initialize-event ((event event))
(with-slots (key display contact character keysym plist code state time
event-window root drawable window child parent root-x root-y x y
width height border-width override-redirect-p same-screen-p
configure-p hint-p kind mode keymap focus-p count major minor
above-sibling place atom selection requestor target property
colormap new-p installed-p format type data name send-event-p)
(the event event)
...))
6) Split up process-next-event so that the modification of the event structure
happens within a defmethod:
(defun process-next-event (display &optional timeout (update-state-p t))
"Process one event. Call UPDATE-STATE iff UPDATE-STATE-P is true. "
(declare (type display display)
(type (or null number) timeout)
(type boolean update-state-p)
(values boolean))
;; Ensure consistent contact states
(when update-state-p (update-state display))
(let* (;; Process any timers that have expired
(interval-until-next-timer (execute-timers display))
;; Compute true timeout
(wait-for-timer-p (when (or (null timeout)
(and interval-until-next-timer
(< interval-until-next-timer timeout)))
interval-until-next-timer))
(event (allocate-event))
(result nil))
(setf (slot-value (the event event) 'display) display)
(setf result
(or (set-event-and-dispatch event display (or wait-for-timer-p timeout))
;; No event read --
;; return true (i.e. no timeout) if we now have a timer ready
(when wait-for-timer-p t)))
;; We could add an unwind protect to ensure that the event is always
;; deallocated (process-next-event is sometimes thrown out of).
;; However, we judge that an unwind-protect all the time is more
;; expensive than garbage collecting an event structure some of the
;; time.
(deallocate-event event)
result))
(defmethod set-event-and-dispatch ((event event) display timeout)
(macrolet ((set-event (&rest parameters)
`(progn ,@(mapcar #'(lambda (parm)
`(setf (slot-value event ',parm) ,parm))
parameters)))
(dispatch (contact)
`(progn
(dispatch-event event event-key send-event-p sequence ,contact)
t)))
;; Wait for an event, copy info into the EVENT structure then call DISPATCH-EVENT
(xlib:event-cond (display :timeout timeout
:force-output-p t
:discard-p t)
((:key-press :key-release :button-press :button-release)
(code time root window child root-x root-y x y
state same-screen-p event-key sequence send-event-p) t
(set-event code time root window child root-x root-y x y
state same-screen-p)
(dispatch window))
>>> Put the rest of the code here. <<<
(:mapping-notify ; Special case
(request start count) t
(mapping-notify display request start count)
(when (eq request :modifier) ; Update the modifier mapping translate table
(get-display-modifier-translate display :update))
t))))
7) If you want, you can go through the rest of CLUE and CLIO changing defuns to
defmethods when it is clear what the classes of the required arguments must be,
so that slot-value calls will be faster.
8) I made this change to clue/clue/intrinsics.lisp (but I can't remember why):
Old:
;; and after-effect function returned...
! (functionp after-effect)
;; and not in the middle of a batch of layout changes...
--- 1641,1650 ----
New:
;; and after-effect function returned...
! (and (functionp after-effect)
! (or (not (symbolp after-effect)) (fboundp after-effect)))
9) In resource.lisp, you can make this change:
Old:
! #+explorer
(defgeneric convert (contact value type)
;; This :argument-precedence-order makes things more efficient.
(:argument-precedence-order type contact value))
--- 178,186 ----
New:
! #+(or explorer pcl)
(defgeneric convert (contact value type)
;; This :argument-precedence-order makes things more efficient.
(:argument-precedence-order type contact value))
10) In clue/clio/buffer.lisp there is a definition of defstruct*.
You can change it to be:
;;; PCL can't (portably) specialize methods on structure classes unless
;;; they are defined with defclass. Use defstruct* to define such structures.
;;; (Note that the :metaclass option is given to defclass.)
(defmacro defstruct* (name &rest slots)
#-pcl
`(defstruct ,name ,@slots)
#+pcl
(flet ((translate-slot (slot &optional initform &key (type t))
`(,slot
:initform ,initform
:type ,type
:initarg ,(intern (string slot) (find-package :keyword))
:accessor ,(intern (format nil "~a-~a" name slot)))))
(let ((pred (intern (format nil "~a-P" name))))
`(progn
(defclass ,name ()
,(mapcar #'(lambda (x) (apply #'translate-slot x)) slots)
(:metaclass structure-class))
(defmethod ,pred ((z t)) nil)
(defmethod ,pred ((z ,name)) t)
(defun ,(intern (format nil "MAKE-~a" name)) (&rest args)
(apply #'make-instance ',name args))))))